Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[yang_models]: yang models for device_metadata, device_neighbor, flex… #4442

Merged
merged 13 commits into from
Nov 18, 2020

Conversation

praveen-li
Copy link
Member

@praveen-li praveen-li commented Apr 17, 2020

…_counters, crm, versions.

Changes:
1.) yang models for device_metadata, device_neighbor, flex_counters, crm, versions.
2.) Test cases for above yang models.
Signed-off-by: Praveen Chaudhary [email protected]

- What I did
Changes:

1.) yang models for device_metadata, device_neighbor, flex_counters, crm, versions.
2.) Test cases for above yang models.

- How I did it
Wrote yang models for device_metadata, device_neighbor, flex_counters, crm, versions based on
https://github.com/Azure/SONiC/blob/master/doc/mgmt/SONiC_YANG_Model_Guidelines.md and
https://github.com/Azure/SONiC/wiki/Configuration

- How to verify it

New Yang Models Testing:

/sonic/src/sonic-yang-models /sonic
running test
running egg_info
writing top-level names to sonic_yang_models.egg-info/top_level.txt
writing sonic_yang_models.egg-info/PKG-INFO
writing dependency_links to sonic_yang_models.egg-info/dependency_links.txt
reading manifest file 'sonic_yang_models.egg-info/SOURCES.txt'
writing manifest file 'sonic_yang_models.egg-info/SOURCES.txt'
running build_ext

----------------------------------------------------------------------
Ran 0 tests in 0.000s

OK
running bdist_wheel
running build
running build_py
(Reading database ... 155852 files and directories currently installed.)
Preparing to unpack .../libyang_1.0.73_amd64.deb ...
Unpacking libyang (1.0.73) over (1.0.73) ...
Setting up libyang (1.0.73) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
Processing triggers for man-db (2.7.6.1-2) ...
(Reading database ... 155852 files and directories currently installed.)
Preparing to unpack .../libyang-cpp_1.0.73_amd64.deb ...
Unpacking libyang-cpp (1.0.73) over (1.0.73) ...
Setting up libyang-cpp (1.0.73) ...
Processing triggers for libc-bin (2.24-11+deb9u4) ...
(Reading database ... 155852 files and directories currently installed.)
Preparing to unpack .../python2-yang_1.0.73_amd64.deb ...
Unpacking python2-yang (1.0.73) over (1.0.73) ...
Setting up python2-yang (1.0.73) ...
(Reading database ... 155852 files and directories currently installed.)
Preparing to unpack .../python3-yang_1.0.73_amd64.deb ...
Unpacking python3-yang (1.0.73) over (1.0.73) ...
Setting up python3-yang (1.0.73) ...
INFO:YANG-TEST:module: sonic-vlan is loaded successfully
INFO:YANG-TEST:module: sonic-extension is loaded successfully
INFO:YANG-TEST:module: sonic-portchannel is loaded successfully
INFO:YANG-TEST:module: sonic-breakout_cfg is loaded successfully
INFO:YANG-TEST:module: sonic-versions is loaded successfully
INFO:YANG-TEST:module: sonic-device_metadata is loaded successfully
INFO:YANG-TEST:module: sonic-types is loaded successfully
INFO:YANG-TEST:module: sonic-flex_counter is loaded successfully
INFO:YANG-TEST:module: sonic-acl is loaded successfully
INFO:YANG-TEST:module: sonic-loopback-interface is loaded successfully
INFO:YANG-TEST:module: sonic-crm is loaded successfully
INFO:YANG-TEST:module: sonic-device_neighbor is loaded successfully
INFO:YANG-TEST:module: sonic-port is loaded successfully
INFO:YANG-TEST:module: sonic-interface is loaded successfully
INFO:YANG-TEST:
------------------- Test 1: Configure a member port in VLAN_MEMBER table which does not exist.---------------------
libyang[0]: Leafref "/sonic-port:sonic-port/sonic-port:PORT/sonic-port:PORT_LIST/sonic-port:port_name" of value "Ethernet156" points to a non-existing leaf. (path: /sonic-vlan:sonic-vlan/VLAN_MEMBER/VLAN_MEMBER_LIST[vlan_name='Vlan100'][port='Ethernet156']/port)
INFO:YANG-TEST:Configure a member port in VLAN_MEMBER table which does not exist. Passed

INFO:YANG-TEST:
------------------- Test 2: FLEX_COUNTER_TABLE_WITH_CORRECT_USED_VALUE no failure.---------------------
INFO:YANG-TEST:FLEX_COUNTER_TABLE_WITH_CORRECT_USED_VALUE no failure. Passed

INFO:YANG-TEST:
------------------- Test 3: Vlan Interface Ip-prefix must condition failure.---------------------
libyang[0]: Must condition "(current() = ../../VLAN_INTERFACE_LIST[vlan_name=current()]/vlan_name)" not satisfied. (path: /sonic-vlan:sonic-vlan/VLAN_INTERFACE/VLAN_INTERFACE_IPPREFIX_LIST[vlan_name='Vlan100'][ip-prefix='2a04:5555:66:7777::1/64']/vlan_name)
libyang[0]: Must condition not satisfied, Try adding Vlan<vlanid>: {}, Example: 'Vlan100': {} (path: /sonic-vlan:sonic-vlan/VLAN_INTERFACE/VLAN_INTERFACE_IPPREFIX_LIST[vlan_name='Vlan100'][ip-prefix='2a04:5555:66:7777::1/64']/vlan_name)
INFO:YANG-TEST:Vlan Interface Ip-prefix must condition failure. Passed

INFO:YANG-TEST:
------------------- Test 4: Configure IP_TYPE as ARP and ICMPV6_CODE in ACL_RULE.---------------------
libyang[0]: When condition "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV6' or .='IPv6ANY'])" not satisfied. (path: /sonic-acl:sonic-acl/ACL_RULE/ACL_RULE_LIST[ACL_TABLE_NAME='NO-NSW-PACL-V4'][RULE_NAME='Rule_40']/ICMPV6_CODE)
INFO:YANG-TEST:Configure IP_TYPE as ARP and ICMPV6_CODE in ACL_RULE. Passed

INFO:YANG-TEST:
------------------- Test 5: CRM_WITH_WRONG_PERCENTAGE must condition failure.---------------------
libyang[0]: Must condition "(((current()='PERCENTAGE' or current()='percentage') and
../acl_counter_high_threshold<100 and
../acl_counter_low_threshold<100) or
(current()!='PERCENTAGE' and current()!='PERCENTAGE'))" not satisfied. (path: /sonic-crm:sonic-crm/CRM/Config/acl_counter_threshold_type)
INFO:YANG-TEST:CRM_WITH_WRONG_PERCENTAGE must condition failure. Passed

INFO:YANG-TEST:
------------------- Test 6: Configure Wrong family with ip-prefix for VLAN_Interface Table---------------------
libyang[0]: Must condition "(contains(../ip-prefix, ':') and current()='IPv6') or     				(contains(../ip-prefix, '.') and current()='IPv4')" not satisfied. (path: /sonic-vlan:sonic-vlan/VLAN_INTERFACE/VLAN_INTERFACE_IPPREFIX_LIST[vlan_name='Vlan100'][ip-prefix='2a04:5555:66:7777::1/64']/family)
INFO:YANG-TEST:Configure Wrong family with ip-prefix for VLAN_Interface Table Passed

INFO:YANG-TEST:
------------------- Test 7: Configure IP_TYPE as ARP and DST_IPV6 in ACL_RULE.---------------------
libyang[0]: When condition "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV6' or .='IPv6ANY'])" not satisfied. (path: /sonic-acl:sonic-acl/ACL_RULE/ACL_RULE_LIST[ACL_TABLE_NAME='NO-NSW-PACL-V6'][RULE_NAME='Rule_20']/DST_IPV6)
INFO:YANG-TEST:Configure IP_TYPE as ARP and DST_IPV6 in ACL_RULE. Passed

INFO:YANG-TEST:
------------------- Test 8: Configure undefined acl_table_type in ACL_TABLE table.---------------------
libyang[0]: Invalid value "LAYER3V4" in "type" element. (path: /sonic-acl:sonic-acl/ACL_TABLE/ACL_TABLE_LIST[ACL_TABLE_NAME='NO-NSW-PACL-V6']/type)
INFO:YANG-TEST:Configure undefined acl_table_type in ACL_TABLE table. Passed

INFO:YANG-TEST:
------------------- Test 9: Configure wrong value for tagging_mode.---------------------
libyang[0]: Invalid value "non-tagged" in "tagging_mode" element. (path: /sonic-vlan:sonic-vlan/VLAN_MEMBER/VLAN_MEMBER_LIST/tagging_mode)
INFO:YANG-TEST:Configure wrong value for tagging_mode. Passed

INFO:YANG-TEST:
------------------- Test 10: Loopback Ip-prefix port-name must condition failure.---------------------
libyang[0]: Must condition "(current() = ../../LOOPBACK_INTERFACE_LIST[loopback_interface_name=current()]/loopback_interface_name)" not satisfied. (path: /sonic-loopback-interface:sonic-loopback-interface/LOOPBACK_INTERFACE/LOOPBACK_INTERFACE_IPPREFIX_LIST[loopback_interface_name='lo1'][ip-prefix='2a04:5555:66:7777::1/64']/loopback_interface_name)
libyang[0]: Must condition not satisfied, Try adding lo<>: {}, Example: 'lo1': {} (path: /sonic-loopback-interface:sonic-loopback-interface/LOOPBACK_INTERFACE/LOOPBACK_INTERFACE_IPPREFIX_LIST[loopback_interface_name='lo1'][ip-prefix='2a04:5555:66:7777::1/64']/loopback_interface_name)
INFO:YANG-TEST:Loopback Ip-prefix port-name must condition failure. Passed

INFO:YANG-TEST:
------------------- Test 11: Configure non-existing ACL_TABLE in ACL_RULE.---------------------
libyang[0]: Leafref "/sonic-acl:sonic-acl/sonic-acl:ACL_TABLE/sonic-acl:ACL_TABLE_LIST/sonic-acl:ACL_TABLE_NAME" of value "NOT-EXIST" points to a non-existing leaf. (path: /sonic-acl:sonic-acl/ACL_RULE/ACL_RULE_LIST[ACL_TABLE_NAME='NOT-EXIST'][RULE_NAME='Rule_20']/ACL_TABLE_NAME)
INFO:YANG-TEST:Configure non-existing ACL_TABLE in ACL_RULE. Passed

INFO:YANG-TEST:
------------------- Test 12: Configure l4_src_port_range as 99999-99999 in ACL_RULE---------------------
libyang[0]: Value "99999-99999" does not satisfy the constraint "([0-9]{1,4}|[0-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-2][0-9]{2}|[6][5][3][0-5]{2}|[6][5][3][6][0-5])-([0-9]{1,4}|[0-5][0-9]{4}|[6][0-4][0-9]{3}|[6][5][0-2][0-9]{2}|[6][5][3][0-5]{2}|[6][5][3][6][0-5])" (range, length, or pattern). (path: /sonic-acl:sonic-acl/ACL_RULE/ACL_RULE_LIST[ACL_TABLE_NAME='NO-NSW-PACL-V6'][RULE_NAME='Rule_20']/L4_SRC_PORT_RANGE)
INFO:YANG-TEST:Configure l4_src_port_range as 99999-99999 in ACL_RULE Passed

INFO:YANG-TEST:
------------------- Test 13: Configure IP_TYPE as ipv4any and SRC_IPV6 in ACL_RULE.---------------------
libyang[0]: When condition "boolean(IP_TYPE[.='ANY' or .='IP' or .='IPV6' or .='IPv6ANY'])" not satisfied. (path: /sonic-acl:sonic-acl/ACL_RULE/ACL_RULE_LIST[ACL_TABLE_NAME='NO-NSW-PACL-V4'][RULE_NAME='Rule_20']/SRC_IPV6)
INFO:YANG-TEST:Configure IP_TYPE as ipv4any and SRC_IPV6 in ACL_RULE. Passed

INFO:YANG-TEST:
------------------- Test 14: CRM_WITH_CORRECT_USED_VALUE no failure.---------------------
INFO:YANG-TEST:CRM_WITH_CORRECT_USED_VALUE no failure. Passed

INFO:YANG-TEST:
------------------- Test 15: VERSIONS_WITH_INCORRECT_PATTERN pattern failure.---------------------
libyang[0]: Value "version_1_2" does not satisfy the constraint "version_([0-9]{2})_([0-9]{2})_([0-9]{2})" (range, length, or pattern). (path: /sonic-versions:sonic-versions/VERSIONS/DATABASE/VERSION)
INFO:YANG-TEST:VERSIONS_WITH_INCORRECT_PATTERN pattern failure. Passed

INFO:YANG-TEST:
------------------- Test 16: Configure empty string as ip-prefix in INTERFACE table.---------------------
libyang[0]: Invalid value "" in "ip-prefix" element. (path: /sonic-interface:sonic-interface/INTERFACE/INTERFACE_IPPREFIX_LIST[ip-prefix='']/ip-prefix)
INFO:YANG-TEST:Configure empty string as ip-prefix in INTERFACE table. Passed

INFO:YANG-TEST:
------------------- Test 17: Configure INNER_ETHER_TYPE as 0x080C in ACL_RULE.---------------------
libyang[0]: Value "0x080C" does not satisfy the constraint "(0x88CC|0x8100|0x8915|0x0806|0x0800|0x86DD|0x8847)" (range, length, or pattern). (path: /sonic-acl:sonic-acl/ACL_RULE/ACL_RULE_LIST[ACL_TABLE_NAME='NO-NSW-PACL-V4'][RULE_NAME='Rule_40']/INNER_ETHER_TYPE)
INFO:YANG-TEST:Configure INNER_ETHER_TYPE as 0x080C in ACL_RULE. Passed

INFO:YANG-TEST:
------------------- Test 18: Add dhcp_server which is not in correct ip-prefix format.---------------------
libyang[0]: Invalid value "10.186.72.566" in "dhcp_servers" element. (path: /sonic-vlan:sonic-vlan/VLAN/VLAN_LIST/dhcp_servers[.='10.186.72.566'])
INFO:YANG-TEST:Add dhcp_server which is not in correct ip-prefix format. Passed

INFO:YANG-TEST:
------------------- Test 19: Configure undefined packet_action in ACL_RULE table.---------------------
libyang[0]: Invalid value "SEND" in "PACKET_ACTION" element. (path: /sonic-acl:sonic-acl/ACL_RULE/ACL_RULE_LIST/PACKET_ACTION)
INFO:YANG-TEST:Configure undefined packet_action in ACL_RULE table. Passed

INFO:YANG-TEST:
------------------- Test 20: Interface Ip-prefix port-name must condition failure.---------------------
libyang[0]: Must condition "(current() = ../../INTERFACE_LIST[port_name=current()]/port_name)" not satisfied. (path: /sonic-interface:sonic-interface/INTERFACE/INTERFACE_IPPREFIX_LIST[port_name='Ethernet8'][ip-prefix='10.0.0.1/30']/port_name)
libyang[0]: Must condition not satisfied, Try adding PORT: {}, Example: 'Ethernet0': {} (path: /sonic-interface:sonic-interface/INTERFACE/INTERFACE_IPPREFIX_LIST[port_name='Ethernet8'][ip-prefix='10.0.0.1/30']/port_name)
INFO:YANG-TEST:Interface Ip-prefix port-name must condition failure. Passed

INFO:YANG-TEST:
------------------- Test 21: Interface Ip-prefix port-name must condition pass.---------------------
libyang[0]: Missing required element "lanes" in "PORT_LIST". (path: /sonic-port:sonic-port/PORT/PORT_LIST[port_name='Ethernet8'])
INFO:YANG-TEST:Interface Ip-prefix port-name must condition pass. Passed

INFO:YANG-TEST:
------------------- Test 22: Configure vlan-id in VLAN_MEMBER table which does not exist in VLAN  table.---------------------
libyang[0]: Leafref "/sonic-vlan:sonic-vlan/sonic-vlan:VLAN/sonic-vlan:VLAN_LIST/sonic-vlan:vlan_name" of value "Vlan200" points to a non-existing leaf. (path: /sonic-vlan:sonic-vlan/VLAN_MEMBER/VLAN_MEMBER_LIST[vlan_name='Vlan200'][port='Ethernet0']/vlan_name)
libyang[0]: Leafref "/sonic-vlan:sonic-vlan/sonic-vlan:VLAN/sonic-vlan:VLAN_LIST/sonic-vlan:vlan_name" of value "Vlan200" points to a non-existing leaf. (path: /sonic-vlan:sonic-vlan/VLAN_MEMBER/VLAN_MEMBER_LIST[vlan_name='Vlan200'][port='Ethernet0']/vlan_name)
INFO:YANG-TEST:Configure vlan-id in VLAN_MEMBER table which does not exist in VLAN  table. Passed

INFO:YANG-TEST:All Test Passed
/sonic/target/debs/stretch/libyang_1.0.73_amd64.deb installed
/sonic/target/debs/stretch/libyang-cpp_1.0.73_amd64.deb installed
/sonic/target/debs/stretch/python2-yang_1.0.73_amd64.deb installed
/sonic/target/debs/stretch/python3-yang_1.0.73_amd64.deb installed
YANG Tests passed

Passed: pyang -f tree ./yang-models/*.yang > ./yang-models/sonic_yang_tree
running egg_info
writing dependency_links to sonic_yang_models.egg-info/dependency_links.txt
writing sonic_yang_models.egg-info/PKG-INFO
writing top-level names to sonic_yang_models.egg-info/top_level.txt
reading manifest file 'sonic_yang_models.egg-info/SOURCES.txt'
writing manifest file 'sonic_yang_models.egg-info/SOURCES.txt'
installing to build/bdist.linux-x86_64/wheel
running install
running install_lib
running install_data
copying ./yang-models/sonic-acl.yang -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
copying ./yang-models/sonic-breakout_cfg.yang -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
copying ./yang-models/sonic-crm.yang -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
copying ./yang-models/sonic-device_metadata.yang -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
copying ./yang-models/sonic-device_neighbor.yang -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
copying ./yang-models/sonic-extension.yang -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
copying ./yang-models/sonic-flex_counter.yang -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
copying ./yang-models/sonic-interface.yang -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
copying ./yang-models/sonic-loopback-interface.yang -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
copying ./yang-models/sonic-port.yang -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
copying ./yang-models/sonic-portchannel.yang -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
copying ./yang-models/sonic-types.yang -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
copying ./yang-models/sonic-versions.yang -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
copying ./yang-models/sonic-vlan.yang -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
copying ./yang-models/sonic_yang_tree -> build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.data/data/yang-models
running install_egg_info
Copying sonic_yang_models.egg-info to build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.egg-info
running install_scripts
creating build/bdist.linux-x86_64/wheel/sonic_yang_models-1.0.dist-info/WHEEL
/sonic

@praveen-li
Copy link
Member Author

@renukamanavalan , @zhenggen-xu , @li-pingmao , @vasant17 , @samaity
FYA, Thanks a lot.

@praveen-li
Copy link
Member Author

retest vsimage please

@praveen-li praveen-li force-pushed the new_yang_models_msft branch 2 times, most recently from 2dad754 to 3f6eaf9 Compare April 23, 2020 20:35
@praveen-li
Copy link
Member Author

Gentle Reminder: Kinldy review when possible.

@renukamanavalan , @zhenggen-xu , @li-pingmao , @vasant17 , @samaity
FYA, Thanks a lot.

@praveen-li
Copy link
Member Author

@renukamanavalan @lguohan

These Yang models are part of our Dynamic Port Breakout branch, I think it is best to merge them in master. + back-port to 202006. Thanks for review.

@praveen-li
Copy link
Member Author

retest vsimage please

@praveen-li
Copy link
Member Author

retest broadcom please

@praveen-li
Copy link
Member Author

retest mellanox please

@praveen-li
Copy link
Member Author

@lguohan @renukamanavalan : I resolved all comments, Kindly review and merge, Thanks a lot for help.

@vadymhlushko-mlnx
Copy link
Contributor

Could you please tell me when this PR is planned to be merged?

@pravch0505
Copy link

@renukamanavalan @lguohan
I feel we can review and merge this PR. Thx a lot.

@praveen-li
Copy link
Member Author

@lguohan: it will help if we can merge this as well, it is risk free PR :).

@praveen-li
Copy link
Member Author

Rebased

@praveen-li
Copy link
Member Author

@renukamanavalan : Rebased this, which inturn asked for the forced push.

This has removed your approval " praveen-li dismissed renukamanavalan’s stale review via 9ad09d2 2 minutes ago". Kindly approve again. Thanks a lot.

Praveen Chaudhary added 13 commits November 11, 2020 17:00
…_counters, crm, versions.

Changes:
1.) yang models for device_metadata, device_neighbor, flex_counters, crm, versions.
Signed-off-by: Praveen Chaudhary [email protected]:
…neighbor, flex_counters, crm, versions.

Changes:
. Test cases for above yang models.
Signed-off-by: Praveen Chaudhary [email protected]
Changes
-- CRM yang models nexthop_group, nexthop_group_member fields.
-- Test for new fileds.
-- sonic-crm.yang: Fix PERCENTAGE -> percentage.

Signed-off-by: Praveen Chaudhary [email protected]
	src/sonic-yang-models/tests/yang_model_tests/yangTest.json
With merge of new Yang models, there should be no extra\unprocessed table in
Test Config.

Signed-off-by: Praveen Chaudhary <[email protected]>
Signed-off-by: Praveen Chaudhary<[email protected]>
RB=
G=lnos-reviewers
R=pchaudhary,pmao,rmolina,samaity,sfardeen,zxu
A=
-- flex counter.
-- versions.
-- tests.

Signed-off-by: Praveen Chaudhary<[email protected]>
-- Fix flex coounter tests.
-- Add PORT_RATES in flex yang.
-- Change SAMPLE CONFIG as per new constraints.

Signed-off-by: Praveen Chaudhary<[email protected]>
@lguohan
Copy link
Collaborator

lguohan commented Nov 17, 2020

retest vsimage please

@lguohan lguohan merged commit 2fe79c2 into sonic-net:master Nov 18, 2020
santhosh-kt pushed a commit to santhosh-kt/sonic-buildimage that referenced this pull request Feb 25, 2021
sonic-net#4442)

Changes:
1.) yang models for device_metadata, device_neighbor, flex_counters, crm, versions.
2.) Test cases for above yang models.
Signed-off-by: Praveen Chaudhary [email protected]:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants